<?php
/**
 * Author: 命中水、
 * Date: 2020/5/17 18:31
 * Email: in1993summer@163.com
 */

namespace App\Repositories\Demand;

use App\Repositories\Repository;

/**
 * Class DemandRepository
 * @package App\Repositories\Demand
 */
class DemandRepository extends Repository
{

    /**
     * 是否置顶
     */
    const IS_TOP = 1;
    const UN_TOP = 0;

    /**
     * @return string
     */
    public function model()
    {
        return \App\Models\Demand\DemandModel::class;
    }

    /**
     * 清除置顶需求（3天）
     *
     * @return mixed
     */
    public function clearTopDemand()
    {
        $time = time() - 259200;

        return $this->model
                    ->where('is_top', self::IS_TOP)
                    ->where('top_time', '<=', $time)
                    ->update(['is_top' => 0, 'top_time' => 0]);
    }

}